home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / cbibcode.arc / STRNSET.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-05  |  546 b   |  20 lines

  1. /* strnset.c  From TC Bible page 293  Use strnset to set a specified number
  2.  of characters in a string, excluding the terminating null, to a specific
  3.  character value */
  4.  
  5. #include <stdio.h>
  6. #include <conio.h>
  7. #include <string.h>
  8. main()
  9. {
  10.     int c;
  11.     size_t len;
  12.     char buf[80];
  13.     printf("Enter a string: ");
  14.     gets(buf);
  15.     printf("Enter character you want half the string set to: ");
  16.     c = getche();
  17.     len = strlen(buf)/2;
  18.     strnset(buf, c, len); /* set first half of string to character in c */
  19.     printf("\nString is now: %s\n", buf);
  20. }